﻿<Window x:Class="P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice.SCSupplierInvoicesDetailsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:basec="clr-namespace:P2.Cuberry.Framework.Helper;assembly=P2.Cuberry.Framework.Helper"    
    
        
        Icon="/P2.Cuberry;component/Images/CuberryIcon32.ico"            
        Title="Peacequare Cuberry" Width="834" Height="553" 
        Background="{DynamicResource P2BackgroundBrush}" 
        Loaded="Window_Loaded"
        Closing="Window_Closing"
        >

    <Window.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/P2.Cuberry.Framework.Layout;component/Styles/Styles.xaml"/>
                <ResourceDictionary Source="/P2.Cuberry.Framework.Layout;component/Styles/CuberryDataGrid.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <Grid.Resources>
            <Image x:Key="SaveIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/save.png" />
            <Image x:Key="CancelIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/cancel.png" />

            <Image x:Key="BookIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/book16.gif" />
            <Image x:Key="CancelTransactionIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/cancelTransaction16.gif" />
            <Image x:Key="UnbookIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/cancelTransaction16.gif" />
            <Image x:Key="Printer2Icon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/printer2.png" />

        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="35" />
            <RowDefinition Height="*"/>
            <RowDefinition Height="35" />
        </Grid.RowDefinitions>

        <!-- Row 0 Start -->
        <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Content="{Translate DialogHeaderSCSupplierInvoiceDetail}" Style="{StaticResource P2DetailViewHeaderTextStyle}" />


        <Separator Margin="0,0,0,0" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Bottom" Height="0"/>
        <!-- Row 0 End -->

        <!-- Row 1: Menu Start -->
        <Border  Grid.Row="1" Grid.Column="0"  Style="{StaticResource P2MenuBorderStyle}">
            <Menu Grid.Row="1" x:Name="menuMain" Style="{StaticResource P2MenuStyle}" >
                <MenuItem x:Name="SaveBtn"  Margin="2,1,0,2" InputGestureText="Ctrl+S" Header="{Translate SaveBtn}" Command="{Binding SCSupplierInvoiceSaveCommand}" Icon="{StaticResource SaveIcon}" Style="{StaticResource P2MenuItemStyle}" Click="SaveBtn_Click" />
                <MenuItem x:Name="CloseBtn" Margin="2,1,0,2" InputGestureText="Ctrl+X" Header="{Translate SaveAndCloseBtn}" Command="{Binding SCSupplierInvoiceCloseCommand}" Icon="{StaticResource CancelIcon}" Style="{StaticResource P2MenuItemStyle}"/>

                <MenuItem x:Name="BookBtn"  Margin="2,1,0,2" Command="{Binding SCSupplierInvoiceBookCommand}"  Header="{Translate BookBtn}" Icon="{StaticResource BookIcon}" Style="{StaticResource P2MenuItemStyle}"/>
                <MenuItem x:Name="CancelTransactionBtn"  Margin="2,1,0,2" Command="{Binding SCSupplierInvoiceCancelCommand}" Header="{Translate CancelTransactionBtn}" Icon="{StaticResource CancelTransactionIcon}" Style="{StaticResource P2MenuItemStyle}"/>
                <MenuItem x:Name="UnbookBtn"  Margin="2,1,0,2" Command="{Binding SCSupplierInvoiceUnbookCommand}"  Header="{Translate UnbookBtn}" Icon="{StaticResource UnbookIcon}" Style="{StaticResource P2MenuItemStyle}"/>

                <MenuItem x:Name="PrintBtn" Margin="2,1,0,2" Header="{Translate PrintBtn}" Click="PrintBtn_Click" Icon="{StaticResource Printer2Icon}" Style="{StaticResource P2MenuItemStyle}"/>
            </Menu>
        </Border>
        <!-- Row 1 End -->

        <!-- Row 2: All Fields -->
        <Border  Grid.Row="2" Grid.Column="0"  Style="{StaticResource P2ContentBorderStyle}">
            <Grid Grid.Row="2" Grid.Column="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="130"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="100"/>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="60"/>
                </Grid.RowDefinitions>
                <Label Height="28" Name="SCSupplierInvoiceHeaderIDL" VerticalAlignment="Top" Content="{Translate SCSupplierInvoiceHeaderIDL}" HorizontalAlignment="Left" Width="150"></Label>
                <TextBox Margin="3,24,0,0" Name="SCSupplierInvoiceHeaderID" Height="23" Text="{Binding SupplierInvoiceHeader, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{StaticResource ErrorTemplate}" HorizontalAlignment="Left"  VerticalAlignment="Top" Style="{StaticResource P2TextBoxStyle}" 
                          IsReadOnly="True"  Width="100" />
                <Label  Name="BookingDateL" Content="{Translate BookingDateL}" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="122" />
                <DatePicker   Margin="0,24,3,0" Name="BookingDate" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" SelectedDate="{Binding BookingDate, Mode=TwoWay , ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  Height="23" VerticalAlignment="Top" 
                                IsEnabled="{Binding NameEnabled}" HorizontalAlignment="Right" Width="122" />


                <Label Grid.Column="1"  Margin="0,1,3,0" Name="SupplierReceiptDateL" Content="{Translate SupplierReceiptDateL}" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="122" />
                <DatePicker Grid.Column="1" Margin="0,24,3,0" Name="SupplierReceiptDate" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" SelectedDate="{Binding SupplierReceiptDate, Mode=TwoWay , ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  Height="23" VerticalAlignment="Top" 
                                IsEnabled="{Binding NameEnabled}" HorizontalAlignment="Right" Width="122" />

                <Label Height="28" Margin="0,48,0,0" Name="SupplierNameL" VerticalAlignment="Top" Content="{Translate SupplierNameL}" HorizontalAlignment="Left" Width="150"></Label>
                <TextBox   Margin="5,72,31,0" Name="SupplierNameCur" Text="{Binding SupplierNameCur, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" Style="{StaticResource P2TextBoxStyle}" Height="23" VerticalAlignment="Top" 
                           Grid.RowSpan="2" />
                <Button Height="23" HorizontalAlignment="Right" Margin="0,72,5,0" Name="FindButton" Command="{Binding FiAccountFindCommand}"  VerticalAlignment="Top" Width="25" Grid.RowSpan="2">
                    <Image  Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/find16.gif"></Image>
                </Button>


                <Label Grid.Column="1"  Height="28" Margin="0,71,2,0" Name="DocumentNoL" VerticalAlignment="Top" Content="{Translate DocumentNoL}" HorizontalAlignment="Right" Width="122" Grid.Row="1"></Label>
                <TextBox Margin="0,95,2,0" Name="DocumentNo" Height="23" Text="{Binding DocumentNo, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" HorizontalAlignment="Right"  VerticalAlignment="Top" Style="{StaticResource P2TextBoxStyle}" 
                          IsReadOnly="{Binding NameReadOnly}" Width="125" Grid.Row="1" Grid.Column="1" />

                <Label Grid.Column="1"  Height="28" Margin="0,46,3,0" Name="SupplierInvoiceNoL" VerticalAlignment="Top" Content="{Translate SupplierInvoiceNoL}" HorizontalAlignment="Right" Width="122" />
                <TextBox Grid.Column="1" Margin="0,69,3,0" Name="SupplierInvoiceNo" Text="{Binding SupplierInvoiceNo , ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" Style="{StaticResource P2TextBoxStyle}" Height="23" VerticalAlignment="Top" 
                          IsReadOnly="{Binding NameReadOnly}" HorizontalAlignment="Right" Width="122" />

                               


                <Label Grid.Row="1" Grid.Column="1" Margin="0,0,5,25" Name="SCSupplierInvoiceFiscalYearL" Content="{Translate FiscalYearIDL}" Height="28" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122"></Label>
                <ComboBox  Grid.Row="1" Grid.Column="1" Margin="0,0,5,8" Name="FiscalYear" ItemsSource="{Binding FiscalYears}"
                          SelectedValue="{Binding FiscalYearID, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" Style="{StaticResource P2ComboBoxStyle}" SelectedValuePath="FiscalYearID" DisplayMemberPath="FiscalYearName" IsEnabled="{Binding FYEnabled}" Height="22" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="122" />


                <Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="5,0,0,43" Name="NoteL" Content="{Translate NoteL}" VerticalAlignment="Bottom" Width="120" Height="23" />
                <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,5,5" Name="Note" Height="43" HorizontalAlignment="Stretch"  VerticalAlignment="Bottom" VerticalScrollBarVisibility="Auto" Style="{StaticResource P2TextBoxStyle}"
                         Text="{Binding Note , ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                         IsReadOnly="{Binding NameReadOnly}"
                         />

                <Grid Grid.Row="1" Grid.Column="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>                        
                    </Grid.RowDefinitions>

                    <Border Grid.Row="0" Margin="5,14,5,5"   VerticalAlignment="Stretch" BorderThickness="1" CornerRadius="2,2,2,2" BorderBrush="#FF6893CF">
                        <Grid ShowGridLines="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="34"/>
                            </Grid.RowDefinitions>
                            
                            <DataGrid Grid.Row="1"  Margin="3,0,3,0" 
                                         Name="SCSupplierInvoiceItemList" 
                                         ItemsSource="{Binding cPayrollItems}"                                         
                                         MouseDoubleClick="SCSupplierInvoiceItemList_MouseDoubleClick"                                          
                                         Style="{DynamicResource CuberryDataGridStyle}"
                                         VerticalAlignment="Top">
                                
                                <DataGrid.Columns>
                                    <DataGridTextColumn   Header="{Translate ProductCodeL}" IsReadOnly="True"  Binding="{Binding ProductCode}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate ProductNameL}" IsReadOnly="True"  Binding="{Binding ProductNameCur}" 
                                                              Width="200" MinWidth="40" />
                                    <DataGridTextColumn Header="{Translate PositionL}" IsReadOnly="True" Binding="{Binding Path=Position, StringFormat=F2}" Width="*" />

                                    <DataGridTextColumn Header="{Translate QuantityL}" IsReadOnly="True" Binding="{Binding Path=Quantity, StringFormat=F2}" Width="200" MinWidth="40" />
                                    <DataGridTextColumn Header="{Translate PricePerUnitL}" IsReadOnly="True" Binding="{Binding Path=PricePerUnit, StringFormat=F2}" Width="*" />
                                    <DataGridTextColumn Header="{Translate VATL}" IsReadOnly="True" Binding="{Binding  Path=VATPercent, StringFormat=F2}" Width="*" />
                                    <DataGridTextColumn Header="{Translate ExpiryDateL}" IsReadOnly="True" Binding="{Binding Path=ExpiryDate,  StringFormat=dd/MM/yyyy}" Width="*" />

                                </DataGrid.Columns>
                            </DataGrid>
                            <Button Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom"  Margin="3,0,0,3" Name="AddPayrollItemBtn"  Command="{Binding SCSupplierInvoiceAddPayrollItemCommand}"  Height="23" Width="23">
                                <Image  Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/add.png" DataContext="{Binding}"></Image>
                            </Button>
                            <Button Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="28,0,0,3" Name="DeletePayrollItemBtn"  Command="{Binding SCSupplierInvoiceDeletePayrollItemCommand}" Height="23"  Width="23">
                                <Image  Source="/P2.Cuberry.Modules.SimpleSCM.SCSupplierInvoice;component/Images/Remove.ico"></Image>
                            </Button>
                            <TextBox Grid.Row="2"  HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,3,3" Name="PayrollItemTotal" Width="120" Text="{Binding PayrollItemsSum, StringFormat=F2, Mode=OneWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" IsReadOnly="True" Style="{StaticResource P2TextBoxStyle}" Height="23" />
                        </Grid>
                    </Border>



               
                </Grid>

            </Grid>
        </Border>

        <!-- Row 2: End -->


        <!-- Row 3: Bottom: Status Bar Start -->
        <Border Grid.Row="3" Grid.Column="0" Style="{StaticResource P2StatusStripBorderStyle}" >
            <Grid Grid.Row="3" Grid.Column="0" Style="{StaticResource P2StatusStripGridStyle}">
                <basec:P2StatusStrip x:Name="StatusStrip" MessageStack2="{Binding MessageStack}" Grid.Column="0" Grid.Row="3" Height="Auto" Width="Auto" Background="White" HorizontalAlignment="Left" ContentStringFormat=""></basec:P2StatusStrip>
                <TextBox Name="Status" Grid.Column="0" Grid.Row="3" Height="Auto" Width="Auto" Background="White" HorizontalAlignment="Right" Text="{Binding StatusName, Mode=OneWay}" IsReadOnly="True" BorderBrush="Transparent" />
            </Grid>
        </Border>

        <!-- Row 3: End -->
    </Grid>
</Window>
